#include<p18F4520.h>
#include <pwm.h>
#include <timers.h>

#pragma config OSC = HS
#pragma config WDT = OFF // turns the watchdog timer off

void main(void)
{
TRISC = 0b11111011;
PORTCbits.RC2 = 0;

OpenPWM1 (0xF0);

OpenTimer2 (TIMER_INT_OFF & T2_PS_1_1 & T2_POST_1_1);

SetDCPWM1 (1024);
}



/*
void OpenEPWM1( char period );
"period" can be any value from 0x00 to 0xff. 
This value determines the PWM frequency by using the following formula:

PWM period =[(period ) + 1] x 4 x TOSC x TMR2 prescaler



Then set the duty cycle with SetDCPWM1

void SetDCPWM1( unsigned int dutycycle );
void SetDCPWM2( unsigned int dutycycle );
"dutycycle" is the value of dutycycle,  a 10-bit number.

You can close the channel with ClosePWM1(2)

*/